<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	
    	$this->display();
    }
    
    public function login(){
        $code = 10010;
        $msg = '请输入账号';
        if(!empty($_POST['user_name'])){
            $msg = '请输入密码';
            if(!empty($_POST['password'])){
                $data['ecm_store.login_password'] = md5($_POST['password']);
                $data['ecm_store.login_name'] = $_POST['user_name'];
                $res = D('member')->getSellerInfo($data);
                $msg = '登陆失败，账号或密码错误';
                if($res) {
                    $_SESSION['seller'] = $res;
                    $code = 10000;
                    $msg = '登陆成功';
                }
            }
        }
        $return_array = array(
            'code' => $code,
            'msg' => $msg
        );
        echo json_encode($return_array);
    }
    public function logout(){
        $_SESSION['seller']  = '';
        $this->redirect(U('Login/index'));
    }
}